/**
 * 部门选择器
 */
var DepLeaders = {
	/**
	 * @param callback　回调函数
	 * @param isSingle　是否单选
	 */
	getView : function(callback,isSingle,map) {
		
	 var tree = new Ext.tree.TreePanel({
        //title: 'My Task List',
        height: 300,
        width: 280,
        useArrows:true,
        autoScroll:true,
        animate:true,
        enableDD:true,
        containerScroll: true,
        rootVisible: false,
        frame: true,
        root: {
            nodeType: 'async'
        },
        
        // auto create TreeLoader
        dataUrl:  __ctxPath + '/system/dep3LeadersTreeDepartment.do',
        
        listeners: {
            'checkchange': function(node, checked){
                if(checked){
                    node.getUI().addClass('complete');
                }else{
                    node.getUI().removeClass('complete');
                }
            }
        }
    });

    tree.getRootNode().expand(true);
		
		var window = new Ext.Window({
					title : '请选择会签部长',
					iconCls:'menu-department',
					width : 300,
					height : 380,
					layout:'form',
					border:false,
					items : [tree],
					modal : true,
					buttonAlign : 'center',
					buttons : [{
								iconCls:'btn-ok',
								text : '确定',
								handler : function() {
					                var userIds = '', userNames='',selNodes = tree.getChecked();
					                Ext.each(selNodes, function(node){
					                    if(userIds.length > 0){
					                        userIds += ',';
					                    }
					                    if(userNames.length > 0){
					                        userNames += ',';
					                    }
					                    userIds += node.id;
					                    userNames += node.text;
					                });
					                
					                if (callback != null) {
											callback.call(this, userIds, userNames);
										}
										window.close();
            				}
							}, {
								text : '取消',
								iconCls:'btn-cancel',
								handler : function() {
									window.close();
								}
							}]
				});
		return window;
	}

};